const { DataTypes } = require("sequelize");
const sequelize = require("./index");

const ExtendArticle = sequelize.define(
	"extend_article",
	{
		id: {
			type: DataTypes.INTEGER,
			primaryKey: true,
			allowNull: false,
			autoIncrement: true,
		},
		title: {
			type: DataTypes.STRING,
			allowNull: false,
		},
		content: {
			type: DataTypes.TEXT,
			allowNull: false,
		},
		createTime: {
			type: DataTypes.DATE,
			allowNull: false,
		},
		desc: {
			type: DataTypes.TEXT,
			allowNull: false,
		},
		cover: {
			type: DataTypes.TEXT,
		},
		extendArticleTypeId: {
			type: DataTypes.INTEGER,
			allowNull: false,
		},
		file: {
			type: DataTypes.TEXT,
		},
		status: {
			type: DataTypes.INTEGER,
			defaultValue: 0,
			comments: "0：未审核；1：审核通过；2：审核不通过"
		}
	},
	{
		timestamps: false,
	}
);

ExtendArticle.associate = ({ extendArticleType }) => {
	ExtendArticle.belongsTo(extendArticleType);
};

module.exports = ExtendArticle;
